import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './components/home/home.component';

//导入路由守卫
import { CheckoutRoleGuard } from './auth/checkoutRole/checkout-role.guard'; // 验证用户权重
import { CheckoutTokenGuard } from './auth/checkoutToken/checkout-token.guard'; // 验证token 是否过期
import { CheckoutRefreshTokenGuard } from './auth/checkoutRefreshToken/checkout-refresh-token.guard'; // // 验证刷新令牌是否过期
const routes: Routes = [
  {
    path: 'home',
    component: HomeComponent,
    children: [
      {
        path: '',
        children: [
          {
            path: 'member-application',
            loadChildren:
              './pages/member-application-inertia/member-application-inertia.module#MemberApplicationInertiaModule',
            canActivate: [
              CheckoutRoleGuard,
              CheckoutTokenGuard,
              CheckoutRefreshTokenGuard
            ] //
          }, // 新成员申请
          {
            path: 'error',
            loadChildren:
              './pages/error-inertia/error-inertia.module#ErrorInertiaModule'
          }, // 权限不足提示页面
          {
            path: 'personal-data',
            loadChildren:
              './pages/personal-data-inertia/personal-data-inertia.module#PersonalDataInertiaModule',
            canActivate: [CheckoutTokenGuard, CheckoutRefreshTokenGuard] //
          }, // 个人资料
          {
            path: 'individualopus',
            loadChildren:
              './pages/individualopus-inertia/individualopus-inertia.module#IndividualopusInertiaModule',
            canActivate: [CheckoutTokenGuard, CheckoutRefreshTokenGuard] //
          }, // 上传的作品
          {
            path: 'shareresource',
            loadChildren:
              './pages/shareresource-inertia/shareresource-inertia.module#ShareresourceInertiaModule',
            canActivate: [CheckoutTokenGuard, CheckoutRefreshTokenGuard] //
          }, // 分享的资源
          {
            path: 'member',
            loadChildren:
              './pages/member-inertia/member-inertia.module#MemberInertiaModule',
            canActivate: [
              CheckoutRoleGuard,
              CheckoutTokenGuard,
              CheckoutRefreshTokenGuard
            ] //
          }, // 所有在职的正式成员
          {
            path: 'upload',
            loadChildren:
              './pages/upload-opus/upload-opus.module#UploadOpusModule',
            canActivate: [CheckoutTokenGuard, CheckoutRefreshTokenGuard] //
          }, // 上传作品
          {
            path: 'resource',
            loadChildren:
              './pages/updateresource-inertia/updateresource-inertia.module#UpdateresourceInertiaModule',
            canActivate: [CheckoutTokenGuard, CheckoutRefreshTokenGuard] //
          }, // 分享资源
          {
            path:'resetpassword',
            loadChildren:'./pages/resetpassword-inertia/resetpassword-inertia.module#ResetpasswordInertiaModule',
            canActivate: [CheckoutTokenGuard, CheckoutRefreshTokenGuard] //
          },// 修改密码
          {
            path: '',
            redirectTo: '/home/personal-data',
            pathMatch: 'full',
            canActivate: [
              CheckoutRoleGuard,
              CheckoutTokenGuard,
              CheckoutRefreshTokenGuard
            ] //
          }
        ]
      }
    ]
  },
  {
    path: 'login',
    loadChildren:
      './pages/login-inertiad/login-inertiad.module#LoginInertiadModule'
  }, //登录
  {
    path: '',
    redirectTo: '/home/member-application',
    pathMatch: 'full',
    canActivate: [
      CheckoutRoleGuard,
      CheckoutTokenGuard,
      CheckoutRefreshTokenGuard
    ] //
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}
